package com.lanou.web.controller;

import com.lanou.entity.TbContent;
import com.lanou.service.ContentService;
import com.lanou.utils.ShiHuiResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by QuChao on 2018/11/25
 */
@RestController
public class ContentController {
    @Autowired
    private ContentService contentService;

    @ApiOperation("获取内容信息")
    @GetMapping("/getContents/{categoryId}")
    public Map<String, Object> getContents(@PathVariable(value = "categoryId") Long categoryId) {
        List<TbContent> list = contentService.getContentsByCategoryId(categoryId);
        return list != null ? ShiHuiResult.ok(list) : ShiHuiResult.error(400);
    }
}
